<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/templates/modelo.xhtml">

	<ui:define name="centro">
		<p:panel id="pnReqPesq" header="Recursos -> Pesquisar"
			rendered="#{recursoBacking.acao == 'pesquisar'}">
			<h:form id="frmRecPesq" prependId="false">
				<h:panelGrid columns="4">
					<h:outputLabel for="txtRecPesquisa" value="Nome:" />
					<p:inputText id="txtRecPesquisa" size="40" maxlength="50"
						value="#{recursoBacking.pesquisa}" />

					<p:commandButton icon="ui-icon-search" type="submit" ajax="false"
						actionListener="#{recursoBacking.buscar}" />
					<p:commandButton icon="ui-icon-plus" type="submit"
						actionListener="#{recursoBacking.novo}" ajax="false" />
				</h:panelGrid>

				<p:dataTable id="dtTblRec" emptyMessage=""
					value="#{recursoBacking.recursos}" var="rec" paginator="true"
					rows="5">

					<p:column>
						<f:facet name="header">
							<h:outputText value="Nome" />
						</f:facet>
						<h:outputText value="#{rec.nome}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Patrimônio" />
						</f:facet>
						<h:outputText value="#{rec.patrimonio}" />
					</p:column>
					
					<p:column>
						<f:facet name="header">
							<h:outputText value="Informações Complementares" />
						</f:facet>
						<h:outputText value="#{rec.informacoesComplementares}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Opções" />
						</f:facet>
						<p:commandButton icon="ui-icon-trash"
							actionListener="#{recursoBacking.excluir}" ajax="false"
							type="submit" />
						<p:commandButton icon="ui-icon-pencil"
							actionListener="#{recursoBacking.editar}" ajax="false"
							type="submit" />
					</p:column>
				</p:dataTable>
			</h:form>
		</p:panel>

		<p:panel header="Recursos -> Novo" 
			rendered="#{recursoBacking.acao != 'pesquisar'}">
			<h:form id="frmRecOp" >
				<h:panelGrid columns="2" rowClasses="verticalTop">
					
					<h:outputLabel for="txtRecPatri" value="Patrimônio:" />
					<p:inputText id="txtRecPatri"
						value="#{recursoBacking.recurso.patrimonio}" size="20"
						maxlength="20" required="true"
						requiredMessage="O campo Patrimônio é obrigatório!"
						disabled="#{recursoBacking.acao == 'excluir'}">
					</p:inputText>
					
					<h:outputLabel for="txtRecDesc" value="Nome:" />
					<p:inputText id="txtRecDesc"
						value="#{recursoBacking.recurso.nome}" size="40"
						maxlength="50" required="true"
						requiredMessage="O campo Nome é obrigatório!"
						disabled="#{recursoBacking.acao == 'excluir'}" />

                     <h:outputLabel for="txtRecDate" value="Data de Entrada:" /> 
                     <p:calendar locale="pt_BR" value="#{recursoBacking.recurso.dataEntrada}" 
                                 id="txtRecDate" showOn="button" pattern="dd/mm/yyyy" required="true"
                                 requiredMessage="O campo Data é obrigatório!"
						         disabled="#{recursoBacking.acao == 'excluir'}">
                     </p:calendar>
                      
                     <h:outputLabel for="txtRecCateg" value="Categoria:" />
                     
                        <p:selectOneMenu id="txtRecCateg" value="#{recursoBacking.recurso.categoria}"    
                        	required="true" requiredMessage="É Obrigatorio selecionar uma Categoria"
                        	converter="categoriaConvert" >
<!--                         	<f:converter converterId="simpleEntityConverter"/> -->
                        	<f:selectItem itemLabel="Selecione" itemValue="" noSelectionOption="true" />    
	                        <f:selectItems value="#{recursoBacking.categorias}" var="cat" 
	                        	itemValue="#{cat}" itemLabel="#{cat.nome}" 
	                        	  />
                        </p:selectOneMenu>
      					
					 <h:outputLabel for="txtRecInf" value="Informações Complementares:" />
					 <p:inputTextarea id="txtRecInf"
                      value="#{recursoBacking.recurso.informacoesComplementares}"
                      rows="5" cols="50" counter="counter" maxlength="500"      
                      counterTemplate="{0} caracteres restantes." autoResize="true"
                      disabled="#{recursoBacking.acao == 'excluir'}"/> 
                       
                     <h:outputText id="counter" />
                                          				
				</h:panelGrid>

				<h:panelGrid columns="4">
					<p:commandButton icon="ui-icon-check" type="submit"
						actionListener="#{recursoBacking.confirmar}" ajax="false" />

					<p:commandButton icon="ui-icon-close" type="submit" ajax="false"
						actionListener="#{recursoBacking.iniciar}" immediate="true" />
				</h:panelGrid>
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>


